package org.jetbrains.sbt.project.modifier.location

import org.jetbrains.plugins.scala.extensions.RichFile
import org.jetbrains.sbt.project.modifier.BuildFileElementType

import java.io.File

object SimpleModuleBuildFileProvider extends BuildFileProvider {

  override def findIoFile(module: com.intellij.openapi.module.Module, elementType: BuildFileElementType): Option[BuildFileEntry[File]] = {
    import org.jetbrains.sbt._
    val buildFile = new File(module.getModuleFilePath).getParentFile / Sbt.BuildFile
    if (buildFile.exists) Some(BuildFileEntry(buildFile, isModuleLocal = true)) else None
  }
}
